<template>
  <basic-container :btnFlag=true>
    <div class="card-border">
      <card-header :header-data="headerData"></card-header>
      <div class="card-body">
        <avue-crud :data="resultData"
                   :option="tableoption"
                   :page="page"
                   :table-loading="tableLoading"
                   @on-load="getResultList"
                   @size-change="sizeChange"
                   @current-change="currentChange"
                   class="avuecrud">
          <template slot-scope="scope" slot="menu">
            <div class="menu-title" style="padding: 8.5px 0px" v-if="scope.row.state=='0'||scope.row.state=='1'">
              <i class="iconfont  icon-primary"></i>
              <p class="menu-title-text"></p>
            </div>
            <div class="menu-title" @click.stop="viewFeedback(scope.row,scope.index)"
                 v-if="scope.row.state!='0'&&scope.row.state!='1'">
              <i class="iconfont iconview icon-primary"></i>
              <p class="menu-title-text">查看反馈</p>
            </div>
          </template>
        </avue-crud>
      </div>
      <el-dialog title="退回理由" :visible.sync="dialogVisible">
        <el-input
          type="textarea"
          v-model="projectForm.opinion"
          rows="3"
        >
        </el-input>
        <div slot="footer" class="dialog-footer">
          <el-button @click="cancel()">取 消</el-button>
          <el-button type="primary" @click="comitYes()">确 定</el-button>
        </div>
      </el-dialog>
    </div>
  </basic-container>
</template>

<script>
  import {opinionTagertList} from "@/api/opinion";
  export default {
    name: "levyFeedbackAllList",
    created() {
    },
    data() {
      return {
        headerData: {
          title: '反馈结果列表'
        },
        resultData: [],
        dialogVisible: false,
        page: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 10 // 每页显示多少条
        },
        tableoption: {
          page: true,
          menuWidth: 120,
          addBtn: false,
          editBtn: false,
          addRowBtn: false,
          indexLabel: "序号",
          index: true,
          indexWidth:70,
          cellBtn: false,
          delBtn: false,
          columnBtn: false,
          refreshBtn: false,
          filterBtn: false,
          searchBtn: false,
          keyId: "id",
          column: [
            {
              label: "征求主题",
              width: 290,
              prop: "title",
              cell: true
            },
            {
              label: "征求意见部门",
              prop: "deptName",
              cell: true
            },
            {
              label: "反馈部门",
              prop: "targetDeptName",
              cell: true
            },
            {
              label: "反馈时间",
              prop: "feedbackTime",
              formatter: function (row, value, label, column) {
                if (row.feedbackTime != null) {
                  var data = row.feedbackTime.split(' ');
                  return data[0];
                }
              },
              cell: true
            },
            {
              label: "状态",
              width: 80,
              prop: "state",
              dicData: [
                {
                  label: '待反馈',
                  value: '0'
                },
                {
                  label: '已反馈',
                  value: '2'
                },
                {
                  label: '退回',
                  value: '1'
                },
              ],
              cell: true,
              formatter: function (row, value, label, column) {
                if (row.state == '0') {
                  return "<font color='red'>" + "催办" + "</font>";
                } else if (row.state == '1') {
                  return "<font color='#DCA450'>" + "待反馈" + "</font>";
                } else if (row.state == '2') {
                  return "<font color='#DCA450'>" + "退回" + "</font>";
                } else if (row.state == '3') {
                  return "<font color='#DCA450'>" + "不采纳" + "</font>";
                } else if (row.state == '4') {
                  return "<font color='#7EBE50'>" + "已反馈" + "</font>";
                } else if (row.state == '5') {
                  return "<font color='#7EBE50'>" + "已采纳" + "</font>";
                }
              }
            },
          ]
        },
        tableLoading: false,
        projectForm: {
          opinion: '',
          targetId: '',
        }

      }
    },
    methods: {
      // 课题详情跳转
      viewFeedback(row) {
        let src = `/subjectCollectionBack/add/${row.opinionId}`;
        this.$router.push({
          path: src,
          query: {
            targetId: row.targetId,
            toDoOrnot: '1',
            state: row.state,
            type:this.$route.query.type,
            relateId:row.relateId
          }
        })
      },
      sizeChange(pageSize) {
        var page = this.page;
        page.pageSize = pageSize;
        this.getResultList(page);
      },
      getResultList(page) {
        opinionTagertList(Object.assign({
          current: page.currentPage,
          size: page.pageSize,
          opinionId: this.$route.params.id
        })).then(response => {
          this.resultData = response.data.data.records;
          this.page.total = response.data.data.total;
        })
      },
    }
  }
</script>

<style lang="scss" scoped>

</style>
